package com.showcai.service.impl;

import com.showcai.log.LogFactory;
import com.showcai.myRunTime.MyRunTimeExcption;
import com.showcai.result.ReturnCode;
import com.showcai.service.VerifyService;
import com.showcai.util.PropertyUtils;
import com.showcai.util.DesTools;
import org.apache.log4j.Logger;

import java.nio.charset.Charset;

/**
 * Created by Baggio on 2018-9-3.
 */
public class VerifyServiceImpl implements VerifyService {
    protected Logger logger = LogFactory.getLogger(getClass());
    private static final String KEY = "app.key";

    @Override
    public String verify(String verifyStr) throws MyRunTimeExcption {
        String kyes = PropertyUtils.getValue(KEY);
        String urlStr = null;
        logger.info("kyes==================》》》》" + kyes);
        try {
            urlStr = DesTools.decrypt(verifyStr, Charset.forName("UTF-8"), kyes);
        } catch (Exception e) {
            e.printStackTrace();
            throw new MyRunTimeExcption(ReturnCode.VERIFY_FAIL);
        }
        return urlStr;
    }
}
